package com.zjitc.obj;

/**
 * Created by lenovo on 2018/3/6.
 */
public class User {
    private String name;
    private Integer age;
    private Home home;

    public User() {
    }

    public User(String name, Integer age, Home home) {
        this.name = name;
        this.age = age;
        this.home = home;
    }

    public User(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public void init(){
        System.out.println("init");
    }

    public Home getHome() {
        return home;
    }

    public void setHome(Home home) {
        this.home = home;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public void close(){
        System.out.println("close");
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ",home="+(home == null ? "" :this.home)+
                '}';
    }
    public static User createInstance(Integer age){
        if (age > 100) {
            return new User("bigger than 100", age);
        } else {
            return new User("smaller than 100", age);
        }

    }
}

